import { View } from "../../../../../mvc/core/View";
import { TigerMachineItem } from "./TigerMachineItem";
import { TweenLite } from "../../../../../../com/greensock/TweenLite";
import { Cubic } from "../../../../../../com/greensock/easing/Cubic";
import { DisplayUtil } from "../../../../../common/DisplayUtil";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { CutDataUtil } from "../../../../../common/tools/CutDataUtil";
import { Cache } from "../../../../cache/Cache";
type int = number;
//class TigerMachineColumn
    
    export  class TigerMachineColumn extends View
    {
        constructor(arg1: int=24, arg2: int=6)
        {
            super();
            this._listArr = [];
            this._duration = arg2;
            this._totalNum = arg1;
            this.initView();
            return;
        }

        public shineResult(arg1: Boolean): void
        {
            this._showItem.shineResult(arg1);
            return;
        }

        /* internal  */initView(): void
        {
            var loc1=null;
            this._container = new Object /* flash.display.Sprite */();
            addChild(this._container);
            loc1 = new Object /* flash.display.Shape */();
            loc1.graphics.beginFill(0);
            loc1.graphics.drawRect(0, 0, TigerMachineItem.DEFAULT_WIDTH + 6, TigerMachineItem.DEFAULT_HEIGHT + 6);
            loc1.graphics.endFill();
            loc1.x = -3;
            loc1.y = -3;
            addChild(loc1);
            this.mask = loc1;
            return;
        }

        public setInitItem(arg1: TigerMachineItem): void
        {
            this._showItem = arg1;
            TweenLite.killTweensOf(this._container, true);
            while (this._container.numChildren > 0) 
            {
                this._container.removeChild(this._container.getChildAt(0));
            }
            this._container.y = -(this._totalNum - 1) * TigerMachineItem.DEFAULT_HEIGHT;
            this._showItem.y = (this._totalNum - 1) * TigerMachineItem.DEFAULT_HEIGHT;
            this._container.addChild(this._showItem);
            return;
        }

        public start(arg1: TigerMachineItem, arg2: TigerMachineItem): void
        {
            var beginItem: TigerMachineItem;
            var targetItem: TigerMachineItem;
            var tmpObj: TigerMachineItem;
            var i: int;

            var loc1;
            tmpObj = null;
            beginItem = arg1;
            targetItem = arg2;
            this.setInitItem(beginItem);
            this._listArr = [];
            i = 0;
            while (i < this._totalNum) 
            {
                if (i != 0) 
                {
                    if (i != (this._totalNum - 1)) 
                    {
                        tmpObj = this.genItem(targetItem);
                        this._container.addChild(tmpObj);
                        tmpObj.y = TigerMachineItem.DEFAULT_HEIGHT * i;
                    }
                    else 
                    {
                        tmpObj == this._showItem;
                    }
                }
                else 
                {
                    tmpObj = targetItem;
                    this._container.addChild(tmpObj);
                    tmpObj.y = TigerMachineItem.DEFAULT_HEIGHT * i;
                }
                tmpObj.shineResult(false);
                this._listArr.push(tmpObj);
                ++i;
            }
            TweenLite.to(this._container, this._duration, {"y": 0, "ease": Cubic.easeInOut, "onComplete":(): void
            {
                var loc1=undefined;
                var loc2=_totalNum;
                var loc3=0;
                while (loc3 < loc2) 
                {
                    loc1 = _listArr[loc3];
                    if (loc3 != 0) 
                    {
                        DisplayUtil.removeMe(loc1);
                    }
                    else 
                    {
                        _showItem = loc1;
                    }
                    ++loc3;
                }
                _listArr = [];
                Dispatcher.dispatchEvent(new DataEvent(EventName.FashionFlyWingTigerStop, 1));
                return;
            }})
            return;
        }

        /* internal  */genItem(arg1: TigerMachineItem): TigerMachineItem
        {
            var loc1=new TigerMachineItem();
            var loc2=CutDataUtil.getRandomNum(Cache.instance.wardrobe.FlyWingAttArr);
            if (arg1 && arg1.attribute == loc2) 
            {
                return this.genItem(arg1);
            }
            loc1.setData(loc2);
            return loc1;
        }

        /* internal */ /* var */_container: Object /* flash.display.Sprite */;

        /* internal */ /* var */_duration: int;

        /* internal */ /* var */_totalNum: int;

        /* internal */ /* var */_listArr: Array<any>;

        /* internal */ /* var */_isPlay: Boolean;

        /* internal */ /* var */_showItem: TigerMachineItem;
    }
